﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class FileTypeElement : SyntaxTreeElement, ITypeElement
    {
        private ITypeElement type;

        public ITypeElement Type { get { return type; } set { type = value; } }

        public FileTypeElement(TokenInfo StartInfo, ITypeElement Type, List<TokenInfo> Comments)
            : base(StartInfo, Comments)
        {
            type = Type;
        }

        public FileTypeElement(TokenInfo StartInfo, List<TokenInfo> Comments) : this(StartInfo, null, Comments) { }

        public override string ToString()
        {
            string result = "file";
            if (type != null) result += string.Format(" of {0}", type);
            return result;
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            if (type != null)
                yield return type;
        }
    }
}
